
package com.insigma.business.qrcode.soldier._bff.impl;



import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.insigma.business.qrcode.common.template.BasePagingResponse;
import com.insigma.business.qrcode.common.util.BizCheckUtil;
import com.insigma.business.qrcode.common.util.SessionUtils;
import com.insigma.business.qrcode.common.vo.BaseResponse;
import com.insigma.business.qrcode.soldier.dto.ExcelResultBO;
import com.insigma.business.qrcode.soldier.dto.PlacementPositionInfoDTO;
import com.insigma.business.qrcode.soldier.dto.gov.BaseProviderImpl;
import com.insigma.business.qrcode.common.template.area.ScenarioCodeEnum;
import com.insigma.business.qrcode.common.template.area.ServiceCallback;
import com.insigma.business.qrcode.soldier.request.BaseGetRequest;
import com.insigma.business.qrcode.soldier.request.PlacementPositionInfoSearchRequest;
import com.insigma.business.qrcode.soldier._bff.PlacementPositionInfoBFFProvider;
import com.insigma.business.qrcode.soldier._consumer.PlacementPositionInfoConsumer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


@Slf4j
@Service
@Component("placementPositionInfoBFFProvider")
public class PlacementPositionInfoBFFProviderImpl extends BaseProviderImpl implements PlacementPositionInfoBFFProvider {

    @Autowired
    private PlacementPositionInfoConsumer placementPositionInfoConsumer;


    @Override
    public BasePagingResponse<List<PlacementPositionInfoDTO>> searchPlacementPositionInfo(final PlacementPositionInfoSearchRequest searchRequest) {

        final BasePagingResponse<List<PlacementPositionInfoDTO>> basePagingResponse = new BasePagingResponse<>();
        serviceTemplate.execute(basePagingResponse, new ServiceCallback() {
            @Override
            public void check() {
                BizCheckUtil.checkNotNull(searchRequest, "查询分页PlacementPositionInfo的请求参数不能为空");
            }

            @Override
            public void executeService() {
                searchRequest.setEmployeeId(SessionUtils.getGovUserId());
                BasePagingResponse<List<PlacementPositionInfoDTO>> listBasePagingResponse = placementPositionInfoConsumer.searchPlacementPositionInfo(searchRequest);
                BeanUtil.copyProperties(listBasePagingResponse, basePagingResponse);
            }

            @Override
            public ScenarioCodeEnum getScenarioEnum() {
                return ScenarioCodeEnum.PLACEMENT_POSITION_INFO_SEARCH;
            }
        });

        return basePagingResponse;
    }

    @Override
    public BasePagingResponse<List<PlacementPositionInfoDTO>> searchPlacementPositionInfoWithUnified(PlacementPositionInfoSearchRequest searchRequest) {

        searchRequest.setEmployeeId(SessionUtils.getGovUserId());
        searchRequest.setYear(String.valueOf(DateUtil.year(new Date())));
        return placementPositionInfoConsumer.searchPlacementPositionInfoWithUnified(searchRequest);
    }

    @Override
    public BasePagingResponse<List<PlacementPositionInfoDTO>> searchPlacementPositionInfoWithUnifiedOfAllAsp(PlacementPositionInfoSearchRequest searchRequest) {

        searchRequest.setEmployeeId(SessionUtils.getGovUserId());
        return placementPositionInfoConsumer.searchPlacementPositionInfoWithUnifiedOfAllAsp(searchRequest);
    }

    @Override
    public BaseResponse<ExcelResultBO> exportPositionAspirationDetail(PlacementPositionInfoSearchRequest placementPositionInfoSearchRequest) {
        return null;
    }


    @Override
    public BasePagingResponse<List<PlacementPositionInfoDTO>> searchCheckList(PlacementPositionInfoSearchRequest searchRequest) {

        BizCheckUtil.checkNotNull(searchRequest, "查询分页PlacementPositionInfo的请求参数不能为空");
        searchRequest.setEmployeeId(SessionUtils.getGovUserId());
        BasePagingResponse<List<PlacementPositionInfoDTO>> listBasePagingResponse = placementPositionInfoConsumer.searchCheckList(searchRequest);
        return listBasePagingResponse;
    }

    @Override
    public BasePagingResponse<List<PlacementPositionInfoDTO>> searchSoldierPositions(PlacementPositionInfoSearchRequest searchRequest) {

        BizCheckUtil.checkNotNull(searchRequest, "查询分页PlacementPositionInfo的请求参数不能为空");
        searchRequest.setSoldierId(SessionUtils.getSoldierUserId());
        return placementPositionInfoConsumer.searchSoldierPositions(searchRequest);
    }

    @Override
    public BaseResponse<PlacementPositionInfoDTO> getPlacementPositionInfo(BaseGetRequest baseGetRequest) {
        return null;
    }

    @Override
    public BaseResponse<PlacementPositionInfoDTO> getByCode(PlacementPositionInfoSearchRequest request) {
        return null;
    }

}
